<?php get_instance()->view('common/header');?>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title"> 首页 </h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li> <i class="fa fa-home"></i> <a href="<?php echo getUrl('home');?>"> 首页  </a></li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <div class="row">
                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="dashboard-stat green">
                        <div class="visual"><i class="fa fa-user"></i></div>
                        <div class="details">
                            <div class="number"><?php echo $totalMerchant?></div>
                            <div class="desc">本月入驻商家：<?php echo $monthTotalMerchant?></div>
                        </div>
                        <a class="more" href="<?php echo getUrl('merchant');?>">
                            查看 <i class="m-icon-swapright m-icon-white"></i>
                        </a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="dashboard-stat purple">
                        <div class="visual"><i class="fa fa-list"></i></div>
                        <div class="details">
                            <div class="number"><?php echo isset($totalOrder) ? $totalOrder : 0?></div>
                            <div class="desc">本月销售：<?php echo isset($monthTotalOrder) ? $monthTotalOrder : 0?></div>
                        </div>
                        <a class="more" href="<?php echo getUrl('order/home');?>">
                            查看 <i class="m-icon-swapright m-icon-white"></i>
                        </a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="dashboard-stat yellow">
                        <div class="visual"><i class="fa fa-list-alt"></i></div>
                        <div class="details">
                            <div class="number"><?php echo $totalProduct?></div>
                            <div class="desc">本月新增商品：<?php echo $monthTotalProduct?></div>
                        </div>
                        <a class="more" href="<?php echo getUrl('product/home');?>">
                            查看 <i class="m-icon-swapright m-icon-white"></i>
                        </a>
                    </div>
                </div>
            </div>
            <div class="row ">
                <div class="col-md-12 col-sm-6">
                    <div class="portlet box red">
                        <div class="portlet-title">
                            <div class="caption"><i class="fa fa-bolt"></i> 平台预警</div>
                        </div>
                        <div class="portlet-body">
                            <ul class="nav nav-tabs ">
                                <li class="active">
                                    <a class="type-btn" href="#1" data-toggle="tab">
                                        超3天未发货订单（<?php echo $otdOrder?>）
                                    </a>
                                </li>
                                <li>
                                    <a class="type-btn" href="#2" data-toggle="tab">
                                        24小时未处理售后单（<?php echo $service?>）
                                    </a>
                                </li>
                                <li>
                                    <a class="type-btn" href="#3" data-toggle="tab">
                                        商户认证申请（<?php echo $merchant?>）
                                    </a>
                                </li>
                                <li>
                                    <a  class="type-btn" href="#4" data-toggle="tab">
                                        商家意见反馈（<?php echo $feedbackCount['merchant']?>）
                                    </a>
                                </li>

                                <li>
                                    <a  class="type-btn" href="#6" data-toggle="tab">
                                        配送员意见反馈（<?php echo $dln_feedback['total']?>）
                                    </a>
                                </li>
                            </ul>
                            <div class="tab-content">
                                <!--超3天未发货订单-->
                                <div class="tab-pane active" id="1">
                                    <div class="table-actions-wrapper"> <span> </span></div>
                                    <table class="table table-bordered table-hover" id="data_table_otd">
                                        <thead>
                                        <tr role="row" class="heading">
                                            <th>编号</th>
                                            <th>商家名称</th>
                                            <th> 会员名称</th>
                                            <th>消费模式</th>
                                            <th>支付方式</th>
                                            <th>订单金额</th>
                                            <th>下单时间 </th>
                                            <th width="8%">状态</th>
                                            <th width="100px">操作</th>
                                        </tr>
                                        <tr>
                                            <th><input class="form-control form-filter input-sm" name="orderCode" type="text"></th>
                                            <th><input class="form-control form-filter input-sm" name="merchant" placeholder="" type="text"></th>
                                            <th><input class="form-control form-filter input-sm" name="consumer" placeholder="" type="text"></th>
                                            <th>
                                                <select name="expenseType" class="form-control form-filter input-sm">
                                                    <option value="" selected="selected">所有</option>
                                                    <?php foreach ($expenseType as $ke => $e):?>
                                                        <option value="<?php echo $ke;?>"><?php echo $e;?></option>
                                                    <?php endforeach;?>
                                                </select>
                                            </th>
                                            <th>
                                                <select name="payType" class="form-control form-filter input-sm">
                                                    <option value="" selected="selected">所有</option>
                                                    <?php foreach ($payType as $k => $v):?>
                                                        <option value="<?php echo $k;?>"><?php echo $v;?></option>
                                                    <?php endforeach;?>
                                                </select>
                                            </th>
                                            <th>
                                                <div class="margin-bottom-5">
                                                    <input class="form-control form-filter input-sm" name="amount_from" placeholder="大于等于" type="text">
                                                </div>
                                                <input class="form-control form-filter input-sm" name="amount_to" placeholder="小于等于" type="text" ></th>
                                            </th>
                                            <th>
                                                <div class="margin-bottom-5">
                                                    <input class="form-control form-filter input-sm" name="add_time_from" dp placeholder="从" type="text">
                                                </div>
                                                <input class="form-control form-filter input-sm" name="add_time_to" dp placeholder="到" type="text" ></th>
                                            </th>
                                            <th>
                                                <select name="orderStatus" class="form-control form-filter input-sm">
                                                    <option value="" selected="selected">所有</option>
                                                    <?php foreach ($status as $k => $v):?>
                                                        <option value="<?php echo $k;?>"><?php echo $v;?></option>
                                                    <?php endforeach;?>
                                                </select>
                                            </th>
                                            <th>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                    <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                    <ul role="menu" class="dropdown-menu pull-right">
                                                        <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                    </ul>
                                                </div>
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <!--24小时未处理售后单-->
                                <div class="tab-pane" id="2">
                                    <div class="table-actions-wrapper"> <span> </span></div>
                                    <table class="table table-bordered table-hover" id="data_table_service">
                                        <thead>
                                        <tr role="row" class="heading">
                                            <th>售后单号</th>
                                            <th>订单号</th>
                                            <th> 商家</th>
                                            <th>退款商品</th>
                                            <th>退款原因</th>
                                            <th>退款金额 </th>
                                            <th>申请时间</th>
                                            <th width="8%">状态</th>
                                            <th width="100px">操作</th>
                                        </tr>
                                        <tr>
                                            <th><input class="form-control form-filter input-sm" name="fHOrderCode" type="text"></th>
                                            <th><input class="form-control form-filter input-sm" name="fHMerchant" placeholder="" type="text"></th>
                                            <th><input class="form-control form-filter input-sm" name="fHConsumer" placeholder="" type="text"></th>
                                            <th>
                                                <select name="fHExpenseType" class="form-control form-filter input-sm">
                                                    <option value="" selected="selected">所有</option>
                                                    <?php foreach ($expenseType as $ke => $e):?>
                                                        <option value="<?php echo $ke;?>"><?php echo $e;?></option>
                                                    <?php endforeach;?>
                                                </select>
                                            </th>
                                            <th>
                                                <select name="fHPayType" class="form-control form-filter input-sm">
                                                    <option value="" selected="selected">所有</option>
                                                    <?php foreach ($payType as $k => $v):?>
                                                        <option value="<?php echo $k;?>"><?php echo $v;?></option>
                                                    <?php endforeach;?>
                                                </select>
                                            </th>
                                            <th>
                                                <div class="margin-bottom-5">
                                                    <input class="form-control form-filter input-sm" name="fh_amount_from" placeholder="大于等于" type="text">
                                                </div>
                                                <input class="form-control form-filter input-sm" name="fh_amount_to" placeholder="小于等于" type="text" ></th>
                                            </th>
                                            <th>
                                                <div class="margin-bottom-5">
                                                    <input class="form-control form-filter input-sm" name="fh_add_time_from" dp placeholder="从" type="text">
                                                </div>
                                                <input class="form-control form-filter input-sm" name="fh_add_time_to" dp placeholder="到" type="text" ></th>
                                            </th>
                                            <th>
                                                <select name="fHOrderStatus" class="form-control form-filter input-sm">
                                                    <option value="" selected="selected">所有</option>
                                                    <?php foreach ($status as $k => $v):?>
                                                        <option value="<?php echo $k;?>"><?php echo $v;?></option>
                                                    <?php endforeach;?>
                                                </select>
                                            </th>
                                            <th>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                    <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                    <ul role="menu" class="dropdown-menu pull-right">
                                                        <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                    </ul>
                                                </div>
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <!--商户认证申请-->
                                <div class="tab-pane" id="3">
                                    <div class="table-actions-wrapper"> <span> </span></div>
                                    <table class="table table-bordered table-hover" id="data_table_merchant">
                                        <thead>
                                        <tr role="row" class="heading">
                                            <th>店铺名称</th>
                                            <th>电话号码</th>
                                            <th>消费类型</th>
                                            <th> 区域</th>
                                            <th>身份证名称</th>
                                            <th>身份证号码</th>
                                            <th>认证时间</th>
                                            <th width="8%">状态</th>
                                            <th width="220px">操作</th>
                                        </tr>
                                        <tr>
                                            <th><input class="form-control form-filter input-sm" name="shop_name" type="text"></th>
                                            <th><input class="form-control form-filter input-sm" name="mobile" type="text"></th>
                                            <th>
                                                <select name="shop_type" class="form-control form-filter input-sm">
                                                    <option value="" selected="selected">所有</option>
                                                    <?php foreach ($shop_type as $k =>$v):?>
                                                        <option value="<?php echo $k?>"><?php echo $v?></option>
                                                    <?php endforeach;?>
                                                </select>
                                            </th>
                                            <th></th>
                                            <th><input class="form-control form-filter input-sm" name="id_name" type="text"></th>
                                            <th><input class="form-control form-filter input-sm" name="identification" type="text"></th>
                                            <th>
                                                <div class="margin-bottom-5">
                                                    <input class="form-control form-filter input-sm" name="send_date_from" dp placeholder="从" type="text">
                                                </div>
                                                <input class="form-control form-filter input-sm" name="send_date_to" dp placeholder="到" type="text" ></th>
                                            </th>
                                            <th>
                                                <select name="shop_status" class="form-control form-filter input-sm">
                                                    <option value="" selected="selected">所有</option>
                                                    <?php foreach ($shopStatus as $k =>$v):?>
                                                        <option value="<?php echo $k?>"><?php echo $v?></option>
                                                    <?php endforeach;?>
                                                </select>
                                            </th>
                                            <th>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                    <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                    <ul role="menu" class="dropdown-menu pull-right">
                                                        <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                    </ul>
                                                </div>
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <!--意见反馈列表-->
                                <div class="tab-pane" id="4">
                                    <div class="table-actions-wrapper"> <span> </span></div>
                                    <table class="table table-bordered table-hover" id="data_merchant">
                                        <thead>
                                        <tr role="row" class="heading">
                                            <th width="120px" sort="false">时间</th>
                                            <th width="120px">商家</th>
                                            <th desc="true" >反馈内容</th>
                                            <th width="100px">状态</th>
                                            <th width="150px">操作</th>
                                        </tr>
                                        <tr>
                                            <th>
                                                <div class="margin-bottom-5">
                                                    <input class="form-control form-filter input-sm" name="send_date_from" dp placeholder="从" type="text">
                                                </div>
                                                <input class="form-control form-filter input-sm" name="send_date_to" dp placeholder="到" type="text">
                                            </th>
                                            <th></th>
                                            <th></th>
                                            <th></th>
                                            <th>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                    <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                    <ul role="menu" class="dropdown-menu pull-right">
                                                        <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                    </ul>
                                                </div>
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <!--意见反馈列表-->

                                <!--意见反馈列表-->
                                <div class="tab-pane" id="6">
                                    <div class="table-actions-wrapper"> <span> </span></div>
                                    <table class="table table-bordered table-hover" id="data_dln">
                                        <thead>
                                        <tr role="row" class="heading">
                                            <th width="120px" sort="false">时间</th>
                                            <th width="120px">商家</th>
                                            <th desc="true" >反馈内容</th>
                                            <th width="100px">状态</th>
                                            <th width="150px">操作</th>
                                        </tr>
                                        <tr>
                                            <th>
                                                <div class="margin-bottom-5">
                                                    <input class="form-control form-filter input-sm" name="send_date_from" dp placeholder="从" type="text">
                                                </div>
                                                <input class="form-control form-filter input-sm" name="send_date_to" dp placeholder="到" type="text">
                                            </th>
                                            <th></th>
                                            <th></th>
                                            <th></th>
                                            <th>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                    <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                    <ul role="menu" class="dropdown-menu pull-right">
                                                        <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                    </ul>
                                                </div>
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="model-modal-feed" style="top: 20%;" class="modal fade modal_small" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title"></h4>
            </div>
            <form action="<?php echo getUrl('home/reply');?>" class="form-horizontal" id="model-form-feed" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-md-3">回复内容 <span class="required">*</span></label>
                        <div class="col-md-9">
                            <textarea class="form-control required" name="reply" style="height: 100px" placeholder="请输入回复内容"></textarea>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="id" value="">
                    <input type="hidden" name="data_type" value="">
                    <button class="btn green field-submit-btn"><i class="fa fa-save"></i> 保存</button>
                    <script type="text/javascript">
                        $(function(){
                            var model = $('#model-modal-feed');

                            /**
                             * 回复
                             */
                            $('.edit-btn').live('click', function(){
                                var p = $(this);
                                var id = p.attr('data-id');
                                model.find('.modal-title').html('回复反馈');
                                model.find('[name="id"]').val(id);
                                model.find('[name="data_type"]').val(p.attr('data-type'));
                                model.find('[name="reply"]').val('');
                                model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                                model.find('.show_message_error').remove();
                                model.modal();
                            });

                            $.e_validate.init('#model-form-feed',{modal:model,ignore:'',successCallback:function(data){
                                var type = data.type;
                                var id = data.id;
                                var obj = '';
                                if(type == 1){
                                    obj = '#data_merchant';
                                }else if(type == 2){
                                    obj = '#data_consumer';
                                }else if(type == 3){
                                    obj = '#data_dln';
                                }
                                var dt = $(obj).find('.edit-btn');
                                dt.each(function(){
                                    if($(this).attr('data-id') == id){
                                        var tr = $(this).parents('tr');
                                        var td = tr.find('.status').parent();
                                        tr.find('.btn').remove();
                                        td.html('<span class="label label-success">已处理</span>');
                                    }
                                });

                            }});

                        });
                    </script>
                </div>
            </form>
        </div>
    </div>
</div>


<script type="text/javascript">
    $(function(){
        // 超3天未发货订单
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#data_table_otd"),
            sAjaxSource: "<?php echo getUrl('home/getOverThreeDaysOrderList');?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [ 0,1,2,3,4,7,8]
            }]
        });

        // 24小时未处理售后单
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#data_table_service"),
            sAjaxSource: "<?php echo getUrl('home/getTwentyFourHoursUntreatedOrderServiceList');?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [ 0,1,2,3,4,5,7,8]
            }]
        });

        // 商户认证申请
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#data_table_merchant"),
            sAjaxSource: "<?php echo getUrl('home/getMerchantAuthenticationList');?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [ 0,1,2,3,4,5,7,8]
            }]
        });

        // 意见反馈
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#data_merchant"),
            sAjaxSource: "<?php echo getUrl('home/getMerchantFeedbackList?type=1');?>",
        });

        // 意见反馈
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#data_dln"),
            sAjaxSource: "<?php echo getUrl('home/getDlnFeedbackList');?>",
        });

        $('[dp]').not("[noinit]").datepicker({
            changeMonth: true,
            autoclose: true,
            format: "yyyy-mm-dd",
            language: 'zh-CN'
        });
    });

    function ajaxRequestCallBack(){
        $('#data_table_merchant').dataTable().fnDraw(true); // 商户认证申请

    }
</script>
</body>
</html>